/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author alberto
 */
@Entity
@Table(name = "recetasinsumos")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Recetasinsumos.findAll", query = "SELECT r FROM Recetasinsumos r"),
    @NamedQuery(name = "Recetasinsumos.findByIdreceta", query = "SELECT r FROM Recetasinsumos r WHERE r.recetasinsumosPK.idreceta = :idreceta"),
    @NamedQuery(name = "Recetasinsumos.findByIdinsumo", query = "SELECT r FROM Recetasinsumos r WHERE r.recetasinsumosPK.idinsumo = :idinsumo"),
    @NamedQuery(name = "Recetasinsumos.findByCantidad", query = "SELECT r FROM Recetasinsumos r WHERE r.cantidad = :cantidad")})
public class Recetasinsumos implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected RecetasinsumosPK recetasinsumosPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CANTIDAD")
    private double cantidad;
    @JoinColumn(name = "IDRECETA", referencedColumnName = "IDRECETA", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Recetas recetas;
    @JoinColumn(name = "IDINSUMO", referencedColumnName = "IDINSUMO", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Insumos insumos;

    public Recetasinsumos() {
    }

    public Recetasinsumos(RecetasinsumosPK recetasinsumosPK) {
        this.recetasinsumosPK = recetasinsumosPK;
    }

    public Recetasinsumos(RecetasinsumosPK recetasinsumosPK, double cantidad) {
        this.recetasinsumosPK = recetasinsumosPK;
        this.cantidad = cantidad;
    }

    public Recetasinsumos(int idreceta, int idinsumo) {
        this.recetasinsumosPK = new RecetasinsumosPK(idreceta, idinsumo);
    }

    public Recetasinsumos(int idreceta, int idinsumo, double cantidad)
    {
        this.recetasinsumosPK = new RecetasinsumosPK(idreceta, idinsumo);
        this.cantidad = cantidad;
    }
    public RecetasinsumosPK getRecetasinsumosPK() {
        return recetasinsumosPK;
    }

    public void setRecetasinsumosPK(RecetasinsumosPK recetasinsumosPK) {
        this.recetasinsumosPK = recetasinsumosPK;
    }

    public double getCantidad() {
        return cantidad;
    }

    public void setCantidad(double cantidad) {
        this.cantidad = cantidad;
    }

    public Recetas getRecetas() {
        return recetas;
    }

    public void setRecetas(Recetas recetas) {
        this.recetas = recetas;
    }

    public Insumos getInsumos() {
        return insumos;
    }

    public void setInsumos(Insumos insumos) {
        this.insumos = insumos;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (recetasinsumosPK != null ? recetasinsumosPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Recetasinsumos)) {
            return false;
        }
        Recetasinsumos other = (Recetasinsumos) object;
        if ((this.recetasinsumosPK == null && other.recetasinsumosPK != null) || (this.recetasinsumosPK != null && !this.recetasinsumosPK.equals(other.recetasinsumosPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Recetasinsumos[ recetasinsumosPK=" + recetasinsumosPK + " ]";
    }
    
}
